package com.it.tydic.estate.module.controller.wxgl;

import com.it.tydic.estate.common.annotation.ControllerDesc;
import com.it.tydic.estate.common.aop.Result;
import com.it.tydic.estate.common.constants.LogConstants;
import com.it.tydic.estate.module.model.inner.TbWxglClmx;
import com.it.tydic.estate.module.service.WxglClmxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 维修管理 材料明细
 * Created by jinghongtao on 2020/3/3.
 */

@RestController
@RequestMapping("/clmx")
@Api(tags ="维修管理———材料明细")
public class WxglClmxController {

    @Resource
    WxglClmxService wxglClmxService;

    /**
     *  分页查询
     * @param record
     * @return
     */
    @ApiOperation("分页查询 材料明细信息")
    @PostMapping("/getDataByPageList")
    public Result getKfxxClmxByPageList(@RequestBody Map<String,Object> record){
        return  wxglClmxService.queryByPage(record);
    }
    /**
     *  条件查询 所有材料明细信息
     * @param
     * @return
     */
   @ApiOperation("根据主表id分页查询 材料明细信息")
    @PostMapping("/getAllData")
    public Result getAllData(@RequestBody Map<String,Object> record){
        return  wxglClmxService.getAllData(record);
    }
    /**
     *  根据id查询 单条
     * @param id
     * @return
     */
    @ApiOperation("根据id查询 单条")
    @GetMapping("/getDataById/{id}")
    public Result getDataById(@PathVariable("id") String id){
        return  wxglClmxService.selectByPrimaryKey(id);
    }

    /**
     * 根据id 删除单条
     * @return
     */
    @ApiOperation("根据id删除单条")
    @ControllerDesc(description = LogConstants.delete_data)
    @DeleteMapping("/deleteData/{id}")
    public Result deleteById(@PathVariable("id") String id){
        return wxglClmxService.deleteById(id);
    }
    /**
     * 根据ids 批量删除
     * @param ids 主键ids数组
     * @return
     */
    @ApiOperation("批量逻辑删除")
    @ControllerDesc(description = LogConstants.delete_data)
    @PostMapping("/deleteByIds")
    public Result deleteByIds(@RequestBody String[] ids) {
        return wxglClmxService.deleteByIds(ids);
    }

    /**
     * 根据id更新
     * @return
     */
    @ApiOperation("根据id更新 材料明细信息")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @PutMapping("/updateData")
    public Result updateData(@RequestBody TbWxglClmx record){
        return wxglClmxService.updateData(record);
    }
    /**
     * 保存
     * @return
     */
    @ApiOperation("新增保存 材料明细信息")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @PostMapping("/saveData")
    public Result saveDate(@RequestBody TbWxglClmx record){
        return wxglClmxService.saveDate(record);
    }
    /**
     * 批量保存或修改
     * @return
     */
    @ApiOperation("批量保存或修改  材料明细信息")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @PostMapping("/saveList/{id}")
    public Result saveList(@RequestBody List<TbWxglClmx> record,@PathVariable("id") String id){
        return wxglClmxService.saveList(record,id);
    }
}
